package cn.zyq.ykb.controller.mgt.config;

import org.springframework.security.access.prepost.PreAuthorize;
import cn.zyq.ykb.system.ry.util.poi.ExcelUtil;
import cn.zyq.ykb.system.common.BaseController;
import cn.zyq.ykb.system.annotation.Log;
import cn.zyq.ykb.system.ry.enums.BusinessType;
import cn.zyq.ykb.beans.config.ConfigInfo;
import cn.zyq.ykb.service.config.ConfigInfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import cn.zyq.ykb.system.common.BaseController;
import cn.zyq.ykb.system.common.PageParam;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 基础信息配置Controller
 *
 * @author SystemAuth
 * @date 2023-05-22
 */

@RestController(value = "MgtConfigInfoController")
@RequestMapping("/mgt/configInfo")
@Api(tags = "基础信息配置接口")
public class ConfigInfoController extends BaseController {

    @Autowired
    private ConfigInfoService configInfoService;

    /**
     * 查询基础信息配置列表
     */
    @ApiOperation(value = "列表", response = ConfigInfo.class)
    @PostMapping("/list")
    public Object list(@RequestBody PageParam pageParam) {
        return this.configInfoService.selectConfigInfoList(pageParam);
    }

//     /**
//      * 导出基础信息配置列表
//      */
//     @ApiOperation(value = "导出")
//     @PreAuthorize("@ss.hasPermi('ykb:configInfo:export')")
//     @Log(title = "基础信息配置" , businessType = BusinessType.EXPORT)
//     @PostMapping("/export")
//     public void export(HttpServletResponse response, ConfigInfo configInfo) {
//         List<ConfigInfo> list = configInfoService.selectConfigInfoList(configInfo);
//         ExcelUtil<ConfigInfo> util = new ExcelUtil<ConfigInfo>(ConfigInfo. class);
//         util.exportExcel(response, list, "基础信息配置数据");
//     }
//
    /**
     * 获取基础信息配置详细信息
     */
    @ApiOperation(value = "详情", response = ConfigInfo.class)
    @GetMapping(value = "/{configInfoID}")
    public Object getInfo(@PathVariable("configInfoID") Integer configInfoID) {
        return this.configInfoService.selectConfigInfoByConfigInfoID(configInfoID);
    }
    /**
     * 获取基础信息配置详细信息
     */
    @ApiOperation(value = "详情", response = ConfigInfo.class)
    @GetMapping(value = "/detail/{serviceID}")
    public Object getInfo(@PathVariable(value = "serviceID") String serviceID) {
        return this.configInfoService.selectConfigInfoByServiceID(serviceID);
    }

    /**
     * 新增基础信息配置
     */
    @ApiOperation(value = "新增")
    @Log(title = "基础信息配置", businessType = BusinessType.INSERT)
    @PostMapping
    public Object add(@RequestBody ConfigInfo configInfo) {
        return this.configInfoService.insertConfigInfo(configInfo);
    }

    /**
     * 修改基础信息配置
     */
    @ApiOperation(value = "编辑")
    @Log(title = "基础信息配置", businessType = BusinessType.UPDATE)
    @PutMapping
    public Object edit(@RequestBody ConfigInfo configInfo) {
        return this.configInfoService.updateConfigInfo(configInfo);
    }

//    /**
//     * 删除基础信息配置
//     */
//    @ApiOperation(value = "删除")
//    @PreAuthorize("@ss.hasPermi('ykb:configInfo:remove')")
//    @Log(title = "基础信息配置", businessType = BusinessType.DELETE)
//    @DeleteMapping("/{configInfoIDs}")
//    public Object remove(@PathVariable Integer[] configInfoIDs) {
//        return this.configInfoService.deleteConfigInfoByConfigInfoIDs(configInfoIDs);
//    }
}
